import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '@/views/Login'

import layout from '@/views/layout'
import Home from '@/views/layout/Home'
import User from '@/views/layout/User'
import Search from '@/views/Search'
import SearchResultList from '@/views/Search/ResultList'


Vue.use(VueRouter)

const routes = [
    // 根路径重定向
    {
        path: '/',
        redirect: '/layout' // 重定向
    },
    {
        path: '/login',
        component: Login
    },
    {
        path: '/layout',
        component: layout,
        redirect: '/layout/home',
        children: [{
            // path:'',
            path: 'home',
            component: Home
        }, {
            path: 'user',
            component: User
        }]
    },
    // 搜索页
    {
        path: '/search',
        component: Search
    },
    // 搜索结果页
    {
        path: '/search/:keyword', // 有: 动态路由
        component: SearchResultList
    }
]

const router = new VueRouter({
    routes
})

export default router